package com.right.health.app.ui.registered.adapter;

import android.content.Context;
import android.text.TextUtils;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.magic.basic.adapter.BaseAbsAdapter;
import com.right.health.app.R;
import com.right.health.app.bean.DoctorDetailResponse;
import com.right.health.app.bean.HomeItem;

/*
 * Created by hopeliao on 2019-09-24
 *
 */
public class DoctorDetailServiceAdapter extends BaseAbsAdapter<DoctorDetailResponse.HealthServiceBean> {


    public DoctorDetailServiceAdapter(Context context) {
        super(context);
    }


    private View.OnClickListener mClickListener;

    public void setOnClickListener(View.OnClickListener listener) {
        this.mClickListener = listener;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder = null;
        if (convertView == null) {
            convertView = mInflater.inflate(R.layout.doctor_detail_follow_service_item, null);
            viewHolder = new ViewHolder();
            viewHolder.nameTv = (TextView) convertView.findViewById(R.id.tv_name);
            viewHolder.contentImage = (ImageView) convertView.findViewById(R.id.iv_content);
            viewHolder.tipsTv = (TextView) convertView.findViewById(R.id.tv_tips);
            convertView.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) convertView.getTag();
        }
        DoctorDetailResponse.HealthServiceBean item = mDataSource.get(position);
        String serviceName = "";
        String price = "";
        int imgResId = 0;
        boolean toChat = false;
        switch (item.getServicetype()) {
            case "0":
                serviceName = "免费咨询";
                imgResId=R.mipmap.ic_doctor_detail_follow1;
                price = "无限期";
                toChat = true;
                break;
            case "1":
                serviceName = "图文咨询";
                imgResId=R.mipmap.ic_doctor_detail_follow2;
                toChat = true;
                break;
            case "2":
                serviceName = "胎心解读";
                imgResId=R.mipmap.ic_doctor_detail_follow3;
                break;
            case "3":
                serviceName = "电话咨询";
                imgResId=R.mipmap.ic_doctor_detail_follow4;
                break;
            case "4":
                serviceName = "视频咨询";
                imgResId=R.mipmap.ic_doctor_detail_follow5;
                break;
        }
        if (!TextUtils.isEmpty(item.getPrice())) {
            price = getString(R.string.format_consult_price, item.getPrice());
        }
      /*  if (toChat && mClickListener != null) {
            convertView.setOnClickListener(mClickListener);
        }*/
        viewHolder.tipsTv.setText(price);
        viewHolder.nameTv.setText(serviceName);
        if (imgResId != 0) {
            viewHolder.contentImage.setImageResource(imgResId);
        }
        return convertView;
    }

    private class ViewHolder {
        private ImageView contentImage;
        private TextView nameTv, tipsTv;
    }
}
